package com.bwie.controller;

import com.bwie.pojo.Type;
import com.bwie.service.TypeService;
import com.bwie.utils.Result;
import com.bwie.vo.TypeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @projectName: server-day0718-pay
 * @package: com.bwie.controller
 * @className: TypeController
 * @author: 陈彤彤
 * @description: TODO
 * @date: 2025/7/21 16:54
 * @version: 1.0
 */
@RestController
@RequestMapping("/prod/type")
@Api(tags = "分类管理")
public class TypeController {

    @Autowired
    TypeService typeService;

    /**
    * @param typeVo:
    * @return Result
    * @author :陈彤彤
    * @description 产品类型分类树
    * @date 2025/7/21 17:27
    */
    @ApiOperation(value = "产品类型分类树")
    @PostMapping("/typeTreeList")
    public Result typeTreeList(@RequestBody TypeVo typeVo){
        return typeService.typeTreeList(typeVo);
    }

    /**
    * @param file:
    * @return Result
    * @author :陈彤彤
    * @description 分类图片上传
    * @date 2025/7/21 20:04
    */
    @ApiOperation(value = "分类图片上传")
    @PostMapping("/uploadFile")
    public Result uploadFile(@RequestPart(name = "file")MultipartFile file){
        return typeService.uploadFile(file);
    }

    /**
    * @param type:
    * @return Result
    * @author :陈彤彤
    * @description 添加分类树信息
    * @date 2025/7/21 20:08
    */
    @ApiOperation(value = "添加分类树信息")
    @PostMapping("/addTypeTree")
    public Result addTypeTree(@RequestBody Type type){
        return typeService.addTypeTree(type);
    }
}
